java logical questions